﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Steamrunner
{
    class LevelFile
    {
        private readonly string filename;

        private List<short> shorts = new List<short>();

        #region Properties
        public string FileName
        {
            get { return filename; }
        }

        public List<short> Shorts
        {
            get { return shorts; }
        }
        #endregion

        public LevelFile(string filename)
        {
            this.filename = filename;
        }

        public void Parse()
        {
            TextReader levelFile = null;

            if (System.IO.File.Exists(filename))
            {
                string line;
                levelFile = new StreamReader(filename);

                line = levelFile.ReadLine();
                while (line != null)
                {
                    for (int i = 0; i < line.Count(); i++)
                    {
                        shorts.Add(short.Parse(line.Substring(i, 1)));
                    }
                    line = levelFile.ReadLine();
                }
                levelFile.Close();
            }
        }
    }
}
